class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        re = set()
        re1 =set()
        max = 0
        for i in range(len(s)):
            l = r = i
            while r<len(s):
                for j in range(l,r+1):
                    re.add(s[j])
                if len(re) == len(s[l:r+1]):
                    max = len(re)
                    re1.add(len(re))
                else:
                    re.clear()
                    r = r+1
                re.clear()
                r = r + 1

        for i in re1:
            if i>max:
                max = i
        return max


if __name__ == "__main__":
    s = "pwwkew"
    a = Solution()
    b = a.lengthOfLongestSubstring(s)
    print(b)
